'use strict';

const Geetest = require('gt3-sdk');

const Controller = require('../../core/common');

var captcha = new Geetest({
  geetest_id: '683898b124098fd661657f731db857aa',
  geetest_key: '3f204e4be8c779614b2ad5caf5a6de8e'
});

class GeeTestController extends Controller {
  async index() {
    const { ctx } = this;

    const data = await new Promise((resolve, reject) => {
      captcha.register(null, (err, data) => {
        if (err) {
          reject(err);
        } else {
          resolve(data);
        }
      });
    });

    this.success(data, 'data');
  }
}

module.exports = GeeTestController;